      SUBROUTINE RDREQMT5A1(LUREQMT,IEXP,MAXEXP,MAXREQEXP,
     *           CH8NAME,KEYREQEXP,REQEXP,LUERR,IERR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE TOSS REQUIREMENTS FILE READER PACKAGE. IT
C READS EXPERIMENT-SPECIFIC DATA. DATA STORAGE OCCURS HERE IF
C NECESSARY(IE, WHEN IEXP>0).  ERROR CHECKS ALSO.
C
C***********************************************************************
C
C BY C PETRUZZO GSFC/742  1/86
C        MODIFIED....
C
C***********************************************************************
C
      INCLUDE 'RDREQMT.INC'
C
      INTEGER*4   KEYREQEXP(MAXREQEXP)
      REAL*8      REQEXP(2,MAXREQEXP,MAXEXP)
      CHARACTER*8 CH8NAME
      CHARACTER*15 KWD
C
      REAL*8 PARMS(MAXPARMS)
      REAL*8    R8VAL/1234567.D0/
      INTEGER*4 I4VAL/1234567/
      REAL*8 HALFPI / 1.570796326794897D0 /
      REAL*8 PI     / 3.141592653589793D0 /
      REAL*8 TWOPI  / 6.283185307179586D0 /
      REAL*8 DEGRAD / 57.29577951308232D0 /
C
C
C SET REQUIREMENTS ARRAY ELEMENTS TO VALUES HAVING THE EFFECT OF NO
C REQUIREMENT ASSIGNED. IT WILL BE OVERRIDDEN IF THE REQUIREMENT IS
C FOUND ON THE FILE.
C
      IF(IEXP.GT.0) THEN
        DO I=1,MAXREQEXP
          IREQ = KEYREQEXP(I)
          IF(IREQ.GT.0 .AND. IREQ.LT.MAXKEYS) THEN
            IF(IREQ.EQ.1) THEN
              REQEXP(1,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.2) THEN
              REQEXP(1,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.3) THEN
              REQEXP(1,I,IEXP) = 0.D0
              REQEXP(2,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.4) THEN
              REQEXP(1,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.5) THEN
              REQEXP(1,I,IEXP) = 0.D0
              REQEXP(2,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.6) THEN
              REQEXP(1,I,IEXP) = 0.D0
              REQEXP(2,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.7) THEN
              REQEXP(1,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.8) THEN
              REQEXP(1,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.9) THEN
              REQEXP(1,I,IEXP) = 0.D0
            ELSE IF(IREQ.EQ.10) THEN
              REQEXP(1,I,IEXP) = PI
              END IF
            END IF
          END DO
        END IF
C
C READ THE KEYWORD RECORDS AND STORE DATA(IF IEXP > 0).
C
 9000 CONTINUE
C      
      CALL MTXSETR8(PARMS,R8VAL,MAXPARMS,1)
      READ(LUREQMT,*,END=9010) KWD,PARMS
      CALL MATCHCH(KWD,MAXKEYS,KEYWORD,KEY)
C
      IF(KEY.EQ.MAXKEYS) GO TO 9999  ! IE, FOUND 'ENDREQ'
      IF(IEXP.EQ.0) GO TO 9000       ! SINCE NO STORING IS NEEDED.
      IF(KEY.EQ.0) GO TO 9020        ! ERROR. NO KEYWORD MATCH.
C
      INDEX = 0
      I = 0
      DO WHILE (INDEX.EQ.0 .AND. I.LT.MAXREQEXP)
        I = I+1
        IF(KEYREQEXP(I).EQ.KEY) INDEX = I
        END DO
C
C    ERROR CHECK.
      IF(INDEX.EQ.0) GO TO 9040
C
      GO TO (100,200,300,400,500,600,700,800,900,1000),KEY
C
C TDRS REQUIREMENT
C
  100 CONTINUE
      IER1 = 0
      KTEMP1 = JIDNNT(PARMS(1))
      IF(KTEMP1.NE.0 .AND. KTEMP1.NE.1 .AND. KTEMP1.NE.2 .AND. 
     *      KTEMP1.NE.12) IER1 = 1
      IF(IER1.EQ.0) THEN
        REQEXP(1,INDEX,IEXP) = KTEMP1
      ELSE
        GO TO 9030
        END IF
      GO TO 9000
C
C DAY/NIGHT REQUIREMENT
C
  200 CONTINUE
      IER1 = 0
      KTEMP1 = JIDNNT(PARMS(1))
      IF(KTEMP1.NE.0 .AND. KTEMP1.NE.1 .AND. KTEMP1.NE.2) IER1 = 1
      IF(IER1.EQ.0) THEN
        REQEXP(1,INDEX,IEXP) = KTEMP1
      ELSE
        GO TO 9030
        END IF
      GO TO 9000
C
C SAA REQUIREMENT
C
  300 CONTINUE
      IF(PARMS(1).EQ.R8VAL .AND. PARMS(2).EQ.R8VAL) IER1 = 1
      IF(IER1.EQ.0) THEN
        IF(PARMS(1).EQ.R8VAL) PARMS(1) = 0.D0
        KTEMP1 = MAX(0,JIDNNT(PARMS(1)))
        IF(PARMS(2).EQ.R8VAL) PARMS(2) = 0.D0
        KTEMP2 = MAX(0,JIDNNT(PARMS(2)))
        REQEXP(1,INDEX,IEXP) = KTEMP1
        REQEXP(2,INDEX,IEXP) = KTEMP2
      ELSE
        GO TO 9030
        END IF
      GO TO 9000
C
C BODY BLOCKAGE REQUIREMENT
C
  400 CONTINUE
      IER1 = 0
      IF(PARMS(1).EQ.R8VAL) IER1 = 1
      IF(IER1.EQ.0) THEN
        KTEMP1 = MAX(0,JIDNNT(PARMS(1)))
        REQEXP(1,INDEX,IEXP) = KTEMP1
      ELSE
        GO TO 9030
        END IF
      GO TO 9000
C
C SUN, MOON AVOIDANCE
C
  500 CONTINUE
  600 CONTINUE
      IER1 = 0
      IF(PARMS(1).EQ.R8VAL .OR. PARMS(2).EQ.R8VAL) IER1 = 1
      KTEMP2 = JIDNNT(PARMS(2))
      IF(KTEMP2.NE.0 .AND. KTEMP2.NE.1) IER1 = 1
      IF(IER1.EQ.0) THEN
        REQEXP(1,INDEX,IEXP) = DMAX1(0.D0,PARMS(1))/DEGRAD
        REQEXP(2,INDEX,IEXP) = KTEMP2
      ELSE
        GO TO 9030
        END IF
      GO TO 9000
C
C VELOCITY VECTOR, BRIGHT AND DARK HORIZON AVOIDANCE
C
  700 CONTINUE
  800 CONTINUE
  900 CONTINUE
      IER1 = 0
      IF(PARMS(1).EQ.R8VAL) IER1 = 1
      IF(IER1.EQ.0) THEN
        REQEXP(1,INDEX,IEXP) = DMAX1(0.D0,PARMS(1))/DEGRAD
      ELSE
        GO TO 9030
        END IF
      GO TO 9000
C
C TARGET AND ZENITH SEPARATION REQUIREMENT
C
 1000 CONTINUE
      IER1 = 0
      IF(PARMS(1).EQ.R8VAL) IER1 = 1
      IF(IER1.EQ.0) THEN
        REQEXP(1,INDEX,IEXP) = PARMS(1)/DEGRAD
      ELSE
        GO TO 9030
        END IF
      GO TO 9000
C
C
C
C ERROR CONDITION. END-FILE SENSED BEFORE 'ENDREQ' OR ID=-9999 WAS READ.
C RDREQMT HAS ALREADY TESTED THE FILE AND FOUND IT OK. TO GET HERE, AN
C ERROR IS PRESENT SOMEWHERE. STOP THE RUN TO FORCE A LOOK THE ERROR.
C
 9010 CONTINUE
      STOP 'CODING ERROR 1. RUN STOPPED. SEE SOURCE CODE IN RDREQMT5A1.'
C
C ERROR CONDITION. INVALID KEYWORD SENSED.  RDREQMT HAS ALREADY TESTED
C THE FILE AND FOUND IT OK. TO GET HERE, AN ERROR IS PRESENT SOMEWHERE.
C STOP THE RUN TO FORCE A LOOK THE ERROR.
C
 9020 CONTINUE
      STOP 'CODING ERROR 2. RUN STOPPED. SEE SOURCE CODE IN RDREQMT5A1.'
C
C ERROR CONDITION. BAD PARAMETER VALUE SENSED.
C
 9030 CONTINUE
      IERR = 1
      IF(LUERR.GT.0) WRITE(LUERR,9901)
     *     'FILE HAS INVALID OR MISSING DATA VALUE.',
     *     'KEYWORD= ' // KWD // '   EXPMT= ' // CH8NAME
      GO TO 9999
C
C ERROR CONDITION. KEYWORD IS INVALID FOR THE CALLING PROGRAM.
C
 9040 CONTINUE
      IERR = 4
      IF(LUERR.GT.0) WRITE(LUERR,9901)
     *     'YOUR PROGRAM DOES NOT ALLOW USE OF AN ' //
     *         'OTHERWISE VALID KEYWORD.',
     *     ' KEYWORD= ' // KWD // '   EXPMT= ' // CH8NAME
      GO TO 9999
C
 9999 CONTINUE
      RETURN
C
 9901 FORMAT(/,
     *   ' OBSERVATION REQUIREMENTS FILE READER. ERROR CONDITION.'/,
     *   (5X,A))    ! ERROR MESSAGE TEXT
      END
